'use strict';
const db = uniCloud.database();
const signin = db.collection('signin');
exports.main = async (event, context) => {
	let {
		name
	} = event
	let res = {}
	switch (event.action) {
		case 'add':
			let obj = {
				"event_id": event.eid,
				"sign_date": Date.parse(new Date()),
				"user_id": event.uid
			}
			res = await signin.add(obj)
			break
		case 'isSignIn':
			res = await signin.where({
				"event_id": event.eid,
				"user_id": event.uid
			}).get()
			break
	}
	return res
};
